#include "global.h"
#include "StrView.h"

std::ostream& operator<<(std::ostream& os, const StrView& view)
{
	return os << std::string_view(view._str.data() + view._beg, view._end - view._beg);
}

bool operator==(const StrView& lhs, const StrView& rhs) noexcept
{
	return std::string_view(lhs._str.data() + lhs._beg, lhs._end - lhs._beg) == std::string_view(rhs._str.data() + rhs._beg, rhs._end - rhs._beg);
}

constexpr std::weak_ordering operator<=>(const StrView& lhs, const StrView& rhs) noexcept
{
	return std::string_view(lhs._str.data() + lhs._beg, lhs._end - lhs._beg) <=> std::string_view(rhs._str.data() + rhs._beg, rhs._end - rhs._beg);
}

template <>
size_t hHash(const StrView& dt)
{
	return std::hash<std::string_view>{}(std::string_view(dt._str.data() + dt._beg, dt._end - dt._beg));
}